#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "std_type.h"


// 当 BLE SPP Server 有连接时回调
typedef void (*FUNC_onBleSppServerConnected)(uint8_t peerMac[6]);
// 当 BLE SPP Server 断开连接时回调
typedef void (*FUNC_onBleSppServerDisconnected)(uint8_t peerMac[6]);
// 当 BLE SPP Server 接收到数据时回调
typedef void (*FUNC_onBleSppServerRxFrame)(uint8_t* data, int len);

typedef struct {
	FUNC_onBleSppServerConnected onConnect;
	FUNC_onBleSppServerDisconnected onDisconnect;
	FUNC_onBleSppServerRxFrame onRxFrame;
} spp_server_callbacks_t;


/// 启动 BLE SPP Server
esp_err_t ble_spp_server_start(const char *bleName, spp_server_callbacks_t *callbacks);
/// 停止 BLE SPP Server
esp_err_t ble_spp_server_stop();
/// BLE SPP Server 连接对端 MAC 地址
/// @return 当前连接的对端 MAC 地址；未连接则返回 NULL
uint8_t* ble_spp_server_get_peer_mac();
/// 发送数据通知到 peer
esp_err_t ble_spp_server_data_notify(const void *data, int len);


#ifdef __cplusplus
}
#endif
